package com.hrbxlh.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.hrbxlh.util.PubMethods;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.hrbxlh.actionImpl.CourseActionImpl;
import com.hrbxlh.actionImpl.ProblemActionImpl;
import com.hrbxlh.util.PropertiesUtil;


/**
* -------------------------------------------------------
* Copyright (c) 2017, 鑫联华信息科技股份有限公司
* All rights reserved.
* FileName：SourceAction.java
* Description：在线问答action类
* History：
* Date           Author               Desc
* 2017.4.19		  sy                   建立
* -------------------------------------------------------
*/

@Controller
public class ProblemAction {
	
	@Autowired
	@Qualifier("problemActionImpl")
	private ProblemActionImpl problemActionImpl;
	
	@Autowired
	@Qualifier("courseActionImpl")
	private CourseActionImpl courseActionImpl;
	
	/**
	 * @param pageNow,pageSize(一般是10)，页数从1开始，第一页pageNow传1
	 * @return  在线问答列表（教师）页面。进页面，翻页，条件查询都是这个。
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getAllProblemList", method = RequestMethod.GET)
	public ModelAndView getAllProblemList(String jsonStr, HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			//模拟参数开始
//			Map<String, Object> mapUse = new HashMap<String, Object>();
//			mapUse.put("pageNow", 1);
//			mapUse.put("pageSize", 10);
//			jsonStr = mapper.writeValueAsString(mapUse);
			//模拟参数结束
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			//获取人员列表信息
			Map<String, Object> resultAllMap = problemActionImpl.getAllProblemList(preParamMap,session);
			if(String.valueOf(resultAllMap.get("errFlag")).equals("success")){
				if(preParamMap.get("problemName")!=null||preParamMap.get("problemName")!=null){
					//搜素框赋值对象
					Map<String,Object> searchObejct = new HashMap<String,Object>();
					searchObejct.put("problemName", preParamMap.get("problemName"));
					resultMap.put("searchObejct", searchObejct);
				}
				
				//查询当前人的消息
				List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
				resultMap.put("noticeList", noticeList);
				
				//返回值
				resultMap.put("problemList", resultAllMap.get("problemList"));
				resultMap.put("courseList", resultAllMap.get("courseList"));
				resultMap.put("stuorteaId", resultAllMap.get("stuorteaId"));
				resultMap.put("totalPage", resultAllMap.get("totalPage"));
				resultMap.put("pageNow", resultAllMap.get("pageNow"));
				resultMap.put("pageSize", preParamMap.get("pageSize"));
				  //人员列表页面名称
				pageName = "pc/problemList";
			}else{
				  //人员列表页面名称
				pageName = "pc/problemList";
			}
			
		  
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转问题列表页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
	
	/**
	 * @param pageNow,pageSize(一般是10)，页数从1开始，第一页pageNow传1
	 * @return  在线问答列表（教师）页面。进页面，翻页，条件查询都是这个。POST
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getAllProblemListByPost", method = RequestMethod.POST)
	public void getAllProblemListByPost(String jsonStr, HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			//模拟参数开始
//			Map<String, Object> mapUse = new HashMap<String, Object>();
//			mapUse.put("pageNow", 1);
//			mapUse.put("pageSize", 10);
//			jsonStr = mapper.writeValueAsString(mapUse);
			//模拟参数结束
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			//获取人员列表信息
			Map<String, Object> resultAllMap = problemActionImpl.getAllProblemList(preParamMap,session);
			if(String.valueOf(resultAllMap.get("errFlag")).equals("success")){
				if(preParamMap.get("problemName")!=null||preParamMap.get("problemName")!=null){
					//搜素框赋值对象
					Map<String,Object> searchObejct = new HashMap<String,Object>();
					searchObejct.put("problemName", preParamMap.get("problemName"));
					resultMap.put("searchObejct", searchObejct);
				}
				
				//查询当前人的消息
				List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
				resultMap.put("noticeList", noticeList);
				
				//返回值
				resultMap.put("problemList", resultAllMap.get("problemList"));
				resultMap.put("courseList", resultAllMap.get("courseList"));
				resultMap.put("stuorteaId", resultAllMap.get("stuorteaId"));
				resultMap.put("totalPage", resultAllMap.get("totalPage"));
				resultMap.put("pageNow", resultAllMap.get("pageNow"));
				resultMap.put("pageSize", preParamMap.get("pageSize"));
				  
			}else{
				 System.out.println("搜索问题出现异常");
				logger.error("搜索问题出现异常");
			}
			
		  
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("搜索问题出现异常", e);
//			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
		
	}
	
	/**
	 * @return  问题详情
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getProblemDetail", method = RequestMethod.GET)
	public ModelAndView getProblemDetail(String jsonStr, HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			
			//模拟参数开始
//			Map<String, Object> mapUse = new HashMap<String, Object>();
//			mapUse.put("pageNow", 1);
//			mapUse.put("pageSize", 10);
//			mapUse.put("problemId", 1);
//			jsonStr = mapper.writeValueAsString(mapUse);
			//模拟参数结束
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			//获取人员列表信息
			Map<String, Object> resultAllMap = problemActionImpl.getProblemDetail(preParamMap,session);
			String[] interfaceNameArrUse = {"server_address","project_name"};
			String[] valueArrUse = PropertiesUtil.getUrl(interfaceNameArrUse);
			String urlUse = "";
			for(String value:valueArrUse){
				urlUse += value;
			}
			//返回图片地址
            String returnUrl= urlUse+"images/pc";
            //查询当前人的消息
			List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			//返回值
			resultMap.put("problemMap", resultAllMap.get("problemMap"));
			resultMap.put("answerList", resultAllMap.get("answerList"));
			resultMap.put("stuorteaId", resultAllMap.get("stuorteaId"));
			resultMap.put("totalPage", resultAllMap.get("totalPage"));
			resultMap.put("pageNow", resultAllMap.get("pageNow"));
			resultMap.put("pageSize", preParamMap.get("pageSize"));
			resultMap.put("imageUrl", returnUrl);
		    //人员列表页面名称
			pageName = "pc/problemDetail";
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转问题详情页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
	
	/**
	 * @param request
	 * @param response
	 * @return  回答问题表单提交。
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/answerProblem", method = RequestMethod.POST)
	public void answerProblem(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(ClassAction.class.getName());
		//成功失败标识
		String resultMark = "fail";
		try {
			
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//成绩设置。
			boolean resultFlag = problemActionImpl.answerProblem(paramMap);
			resultMark = (resultFlag) ? "success" : "fail";
			resultMap.put("result", resultMark);
			if(resultMark.equals("fail")){
				resultMap.put("errorMsg", "回答问题失败");
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("回答问题出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @param request
	 * @param response
	 * @return  提问问题表单提交。
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/putProblem", method = RequestMethod.POST)
	public void putProblem(String jsonStr, HttpServletRequest request, HttpServletResponse response) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(ClassAction.class.getName());
		//成功失败标识
		String resultMark = "fail";
		try {
			
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//成绩设置。
			boolean resultFlag = problemActionImpl.putProblem(paramMap);
			resultMark = (resultFlag) ? "success" : "fail";
			resultMap.put("result", resultMark);
			if(resultMark.equals("fail")){
				resultMap.put("errorMsg", "回答问题失败");
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("回答问题出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	
	/**
	 * @param pageNow,pageSize(一般是10)，页数从1开始，第一页pageNow传1
	 * @return  在线问答列表（学生）页面。进页面，翻页，条件查询都是这个。
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getStuAllProblemList", method = RequestMethod.GET)
	public ModelAndView getStuAllProblemList(String jsonStr, HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			//模拟参数开始
//			Map<String, Object> mapUse = new HashMap<String, Object>();
//			mapUse.put("pageNow", 1);
//			mapUse.put("pageSize", 10);
//			jsonStr = mapper.writeValueAsString(mapUse);
			//模拟参数结束
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			//获取人员列表信息
			Map<String, Object> resultAllMap = problemActionImpl.getStuAllProblemList(preParamMap,session);
			if(preParamMap.get("problemName")!=null||preParamMap.get("problemName")!=null){
				//搜素框赋值对象
				Map<String,Object> searchObejct = new HashMap<String,Object>();
				searchObejct.put("problemName", preParamMap.get("problemName"));
				resultMap.put("searchObejct", searchObejct);
			}
			
			//查询当前人的消息
			List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			
			//返回值
			resultMap.put("problemList", resultAllMap.get("problemList"));
			resultMap.put("courseList", resultAllMap.get("courseList"));
			resultMap.put("stuorteaId", resultAllMap.get("stuorteaId"));
			resultMap.put("totalPage", resultAllMap.get("totalPage"));
			resultMap.put("pageNow", resultAllMap.get("pageNow"));
			resultMap.put("pageSize", preParamMap.get("pageSize"));
		    //页面名称
			pageName = "pc/problemList";
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转问题列表页面出现异常", e);
			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			returnMap.put("result", reJsonStr);
			System.out.println("返回的  :" + reJsonStr);
		}
		return new ModelAndView(pageName, returnMap);
	}
	
	/**
	 * @param pageNow,pageSize(一般是10)，页数从1开始，第一页pageNow传1
	 * @return  在线问答列表（学生）页面。进页面，翻页，条件查询都是这个。
	 * @throws IOException
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getStuAllProblemListByPost", method = RequestMethod.POST)
	public void getStuAllProblemListByPost(String jsonStr, HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {		
		
		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//日志信息
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		try {
			//模拟参数开始
//			Map<String, Object> mapUse = new HashMap<String, Object>();
//			mapUse.put("pageNow", 1);
//			mapUse.put("pageSize", 10);
//			jsonStr = mapper.writeValueAsString(mapUse);
			//模拟参数结束
			
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			//获取人员列表信息
			Map<String, Object> resultAllMap = problemActionImpl.getStuAllProblemList(preParamMap,session);
			if(preParamMap.get("problemName")!=null||preParamMap.get("problemName")!=null){
				//搜素框赋值对象
				Map<String,Object> searchObejct = new HashMap<String,Object>();
				searchObejct.put("problemName", preParamMap.get("problemName"));
				resultMap.put("searchObejct", searchObejct);
			}
			
			//查询当前人的消息
			List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);
			
			//返回值
			resultMap.put("problemList", resultAllMap.get("problemList"));
			resultMap.put("courseList", resultAllMap.get("courseList"));
			resultMap.put("stuorteaId", resultAllMap.get("stuorteaId"));
			resultMap.put("totalPage", resultAllMap.get("totalPage"));
			resultMap.put("pageNow", resultAllMap.get("pageNow"));
			resultMap.put("pageSize", preParamMap.get("pageSize"));
		    
		} catch (Exception e) {
			resultMap.put("errMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("跳转问题列表页面出现异常", e);
//			pageName = "public/pageerror";
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getProblemDetailOther", method = RequestMethod.POST)
	public void getProblemDetailOther(String jsonStr, HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		Logger logger = Logger.getLogger(MemberAction.class.getName());
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		try {
			logger.info("问题详情参数为："+jsonStr);
			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			//获取人员列表信息
			Map<String, Object> resultAllMap = problemActionImpl.getProblemDetailOther(preParamMap,session,request);
			String[] interfaceNameArrUse = {"server_address","project_name"};
			String[] valueArrUse = PropertiesUtil.getUrl(interfaceNameArrUse);
			String urlUse = "";
			for(String value:valueArrUse){
				urlUse += value;
			}
			//返回图片地址
			String returnUrl= urlUse+"upload/images/";
			//查询当前人的消息
			/*List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
			resultMap.put("noticeList", noticeList);*/
			//返回值
			resultMap.put("problemMap", resultAllMap.get("problemMap"));
			resultMap.put("answerList", resultAllMap.get("answerList"));
			resultMap.put("stuorteaId", resultAllMap.get("stuorteaId"));
			resultMap.put("totalPage", resultAllMap.get("totalPage"));
			resultMap.put("pageNow", resultAllMap.get("pageNow"));
			resultMap.put("excuseMark", resultAllMap.get("excuseMark"));
			resultMap.put("pageSize", preParamMap.get("pageSize"));
			resultMap.put("imageUrl", returnUrl);
			resultMap.put("isMark", preParamMap.get("isMark"));
			resultMap.put("result", "success");
			resultMap.put("failMsg", "");
		} catch (Exception e) {
			resultMap.put("result", "fail");
			resultMap.put("failMsg", "跳转页面失败");
			e.printStackTrace();

		} finally {
			logger.info("问题详情返回结果为："+resultMap);
			reJsonStr = mapper.writeValueAsString(resultMap);
			System.out.println("返回的："+reJsonStr);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/answerProblemOther", method = RequestMethod.POST)
	public void answerProblemOther(String jsonStr, HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {
		Logger logger = Logger.getLogger(MemberAction.class.getName());

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//返回字符串
		String reJsonStr = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		//成功失败标识
		String resultMark = "fail";
		try {
			logger.info("回答问题表单提交的参数为："+jsonStr);
			//获取参数值
			Map<String,Object> paramMap = mapper.readValue(jsonStr, resultMap.getClass());
			//成绩设置。
			boolean resultFlag = problemActionImpl.answerProblemOther(paramMap,request,session);
			resultMark = (resultFlag) ? "success" : "fail";
			resultMap.put("result", resultMark);
			if(resultMark.equals("fail")){
				resultMap.put("errorMsg", "回答问题失败");
			}
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("回答问题出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			logger.info("回答问题表单返回结果为："+resultMap);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}
	}
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/getAllProblemListByPostMoble", method = RequestMethod.POST)
	public void getAllProblemListByPostMoble(String jsonStr, HttpServletRequest request, HttpServletResponse response,HttpSession session) throws IOException {
		Logger logger = Logger.getLogger(MemberAction.class.getName());

		//转换json格式工具
		ObjectMapper mapper = new ObjectMapper();
		//存放返回值
		Map<String, Object> returnMap = new HashMap<String, Object>();
		//返回字符串
		String reJsonStr = "";
		//存放页面
		String pageName = "";
		//存放结果值
		Map<String,Object> resultMap = new HashMap<String,Object>();
		try {
			//模拟参数开始
//			Map<String, Object> mapUse = new HashMap<String, Object>();
//			mapUse.put("pageNow", 1);
//			mapUse.put("pageSize", 10);
//			jsonStr = mapper.writeValueAsString(mapUse);
			//模拟参数结束

			//获取页面参数值
			Map<String, Object> preParamMap = mapper.readValue(jsonStr, returnMap.getClass());
			logger.info("在线问答列表（教师）的参数为："+jsonStr);
			//获取人员列表信息
			Map<String, Object> resultAllMap = problemActionImpl.getAllProblemListOther(preParamMap,session,request);
			if(String.valueOf(resultAllMap.get("errFlag")).equals("success")){
				if(preParamMap.get("problemName")!=null||preParamMap.get("problemName")!=null){
					//搜素框赋值对象
					Map<String,Object> searchObejct = new HashMap<String,Object>();
					searchObejct.put("problemName", preParamMap.get("problemName"));
					resultMap.put("searchObejct", searchObejct);
				}

				//查询当前人的消息
				/*List<Map<String, Object>> noticeList = courseActionImpl.getMyNotice(request);
				resultMap.put("noticeList", noticeList);*/

				//返回值
				resultMap.put("problemList", resultAllMap.get("problemList"));
				resultMap.put("courseList", resultAllMap.get("courseList"));
				resultMap.put("stuorteaId", resultAllMap.get("stuorteaId"));
				resultMap.put("totalPage", resultAllMap.get("totalPage"));
				resultMap.put("pageNow", resultAllMap.get("pageNow"));
				resultMap.put("pageSize", preParamMap.get("pageSize"));
				resultMap.put("excuseMark", resultAllMap.get("excuseMark"));
				resultMap.put("result", "success");
				resultMap.put("failMsg", "");

			}else{
				resultMap.put("problemList", null);
				resultMap.put("courseList", null);
				resultMap.put("errMsg", resultAllMap.get("errMsg"));
				resultMap.put("stuorteaId", resultAllMap.get("stuorteaId"));
				resultMap.put("totalPage", 0);
				resultMap.put("result", "success");
				resultMap.put("failMsg", "在线问答列表中当前课程暂无问题");
				logger.info("在线问答列表中当前课程暂无问题");
			}

		} catch (Exception e) {
			resultMap.put("result", "fail");
			resultMap.put("failMsg", "跳转页面失败");
			e.printStackTrace();
			logger.error("在线问答列表（教师）出现异常", e);
		} finally {
			reJsonStr = mapper.writeValueAsString(resultMap);
			logger.info("在线问答列表（教师）返回的结果为："+resultMap);
			response.setContentType("text/html;charset=UTF-8");
			PrintWriter write = response.getWriter();
			write.println(reJsonStr);
			write.flush();
		}

	}
}
